#ifndef MLIFEOBJECT_H
#define MLIFEOBJECT_H

#include "memorypool.h"

/**
 * @brief The MLifeObject class
 * Enable any class that inherits MLifeObject to use features of MemoryPool.
 * If we have many objects that be released together at some point,
 * we can use this pool instead of MObject, as it will save much time from
 * recycling memory
 */

class MLifeObject
{
    static MemoryPool* spPoolInstance;

public:
    static MemoryPool& rGetMemoryPool( size_t initialBlockSize= DEFAULT_BLOCK_SIZE );
    static void destroyMemoryPool();
    MLifeObject();

    inline void* operator new (size_t size)
    {
        MemoryPool& memPool = rGetMemoryPool();
        return memPool.allocate(size);
    }

    void* operator new (std::size_t size, void* ptr)
    {
        return ptr;
    }

    inline void operator delete ( void*  )
    {
        ;//No implementation for delete
    }
};

#endif // MLIFEOBJECT_H
